-
-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for renaming columns within a table #689
Conversation
Welcome back @gjeck, this is a great addition! I'll be off for a few weeks, but I'll be glad to merge your pull request when I'm back. Quick notes: I would be glad if the feature would be enabled when possible: custom SQLite, SQLCipher, maybe some versions of macOS, and maybe not all versions of iOS, tvOS, and warchOS. This is not a very fun task, I agree, but it's a habit here. Also, it looks like the feature does not need to use ColumnDefinition, and that plain Strings would be just enough. Don't feel compelled to address those points, but they both look like they have to be solved before the changes are shipped on master. |
Thank you for the notes @groue! I will make sure to get those changes in. It looks like custom sqlite is pinned at 3.30.1 so that should be straightforward to support. Do you happen to have an area of the code shedding light on the version requirements of SQLCipher? Apologies, but I am not familiar with this 😅 |
Sure @gjeck! Check for example the definition of As you see, we can't avoid some duplication of code and documentation. This is real ugly, but this is what we need for our feature :-) |
From the failed build on de6f9b7 it looks like If there was a way we could expose |
SQLCipher tests don't have good Travis logs (I hadn't the opportunity to fix this).
|
Indeed SQLCipher 3.4.2 reports... SQLite version 3.24.0: String.fetchOne(db, sql: "PRAGMA cipher_version") // "3.4.2"
sqlite3_libversion_number() // 3024000 The need for distinguishing SQLCipher 3 from SQLCipher 4 has not arisen yet, so we enter uncharted territory :-)
Swift can't perform such check. There is no C preprocessor :-) Let's not block this pull request with this problem:
|
In order to reduce code duplication, you can: #if ...
/// doc...
public func foo(...) { _foo(...) }
#else
/// doc...
@available(...)
public func foo(...) { _foo(...) }
#endif
private func _foo(...) { /* the real job */ } |
SQLite introduced enhancements to the `ALTER TABLE` command in 3.25.0. iOS 13.0+, macOS 10.15+, tvOS 13.0+, and watchOS 6.0+ have a SQLite library bundled higher than 3.25.0. For more information see https://www.sqlite.org/lang_altertable.html
Note: SQLCipher3 will have the new column rename method exposed, but it will throw an error at runtime if used.
Yeah, I'm leaving tomorrow :-) Don't expect any answer until mid February. I'll be happy to catch up then :-) |
Sounds great! Enjoy your time off 🌴 |
Thank you very much @gjeck, this is perfect :-) |
Shipped in v4.10.0! Sorry for the delay. |
Summary:
This adds support for renaming columns within a table using ALTER TABLE table RENAME COLUMN oldname TO newname.
SQLite 3.25.0 introduced this feature in 2018 and newer os versions should have bundled versions higher than 3.25.0. Unfortunately, this is not true for macOS.
Example:
Pull Request Checklist:
Wasn't sure if I should update documentation for a feature only available on very new os versions.
development
branch.